package com.itmiaojie.config;

import com.itmiaojie.quartz.MyJob;
import com.itmiaojie.quartz.ViewCountJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig  {

    @Bean
    public JobDetail jobDetail(){
                return JobBuilder.newJob(ViewCountJob.class).storeDurably().build();
    }

    @Bean
    public Trigger trigger(){
        ScheduleBuilder schedBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
        return TriggerBuilder
                .newTrigger()
                .forJob(jobDetail())
                .withSchedule(schedBuilder)
                .build();
    }


}
